// pages/app/certification/resultAllPass/resultAllPass.js
const app = getApp();
var host = app.globalData.host;
var utils = app.globalData.utils;
const base64 = require('../../../../utils/base64.js')
var self = null;

Page({
  data: {
    themeColor: '',
    themeColor2: '',
    defaultColor: '',
    borderColor: '',
    certificateId: '',
    info: {}
  },
  onLoad: function (options) {
    self = this;
    self.getStyle();
    self.setData({
      certificateId: options.id
    })
    console.log(self.data.certificateId);
    self.init();
  },
  getStyle() {
    self.setData({
      themeColor: app.globalData.themeColor,
      themeColor2: app.globalData.themeColor2,
      defaultColor: app.globalData.defaultColor,
      borderColor: app.globalData.borderColor
    })
  },
  init() {
    var url = host + '/lx/mini/question/certificateInfo';
    var params = {
      certificateId: self.data.certificateId
    };
    var success = function (res) {
      var info = res.info;
      var postfix = "?watermark/3/text/{}/font/dGltZXMgbmV3IHJvbWFu/fontsize/2000/fill/IyM2NDY0NjQ=/dissolve/85/gravity/Center/dx/0/dy/-120/text/U3VwZXJsaW5rcGx1cw==/font/dGltZXMgbmV3IHJvbWFu/fontsize/2000/fill/IyM2NDY0NjQ=/dissolve/85/gravity/Center/dx/0/dy/130";
      postfix = postfix.replace("{}", base64.encode(app.globalData.userInfo.firstName + " " + app.globalData.userInfo.lastName));
      info.image += postfix;
      self.setData({
        info: info
      })
    };
    var fail = function (res) { };
    var complete = function () { };
    utils.request(url, params, success, fail, complete);
  },
  goBack(event) {
    wx.navigateBack({
      delta: 2
    })
  }
})